//
//  YYJ_NetRequest.h
//  miaoxiaqianbao
//
//  Created by Lonely丶晏袁杰 on 2018/10/9.
//  Copyright © 2018年 Lonely`yyj. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "YYJ_Common.h"

NS_ASSUME_NONNULL_BEGIN

@interface YYJ_NetRequest : NSObject
+(instancetype)shareNetRequest;


/**定义请求成功的block*/
typedef void(^requestCache)(id responseObject);
/**定义请求成功的block*/
typedef void(^requestSuccess)(id responseObject);
/**定义请求失败的block*/
typedef void(^requestFailure)( NSError * _Nullable error);
/**定义上传进度block*/
typedef void(^uploadProgress)(float progress);
/**定义下载进度block*/
typedef void(^downloadProgress)(float progress);

-(void)requestWithType:(HttpRequestType)type withUrlString:(NSString *)urlString withParaments:(id)paraments jsonCacheBlock:(__nullable requestCache)jsonCache withSuccessBlock:(requestSuccess)successBlock withFailureBlock:(requestFailure)failureBlock progress:(__nullable downloadProgress)progress;

#pragma mark 带有进度的上传
-(NSURLSessionDownloadTask *)postRequest:(NSString *)strUrl andParameters:(id)parameters andPostData:(NSData *)data andFileName:(NSString *)fileName andMimeType:(NSString *)mimeType withSuccessBlock:(requestSuccess)successBlock withFailureBlock:(requestFailure)failureBlock progress:(uploadProgress)progress;
#pragma mark - 文件下载
/**
 *  文件下载
 *
 *  @param operations   文件下载预留参数---视具体情况而定 可移除
 *  @param savePath     下载文件保存路径
 *  @param urlString    请求的url
 *  @param successBlock 下载文件成功的回调
 *  @param failureBlock 下载文件失败的回调
 *  @param progress     下载文件的进度显示
 */
-(NSURLSessionDownloadTask *)downLoadFileWithOperations:(NSDictionary *)operations withSavaPath:(NSString *)savePath withUrlString:(NSString *)urlString withSuccessBlock:(requestSuccess)successBlock withFailureBlock:(requestFailure)failureBlock withDownLoadProgress:(downloadProgress)progress;
//-(NSURLSessionDownloadTask *)downLoadFileWithOperations:(NSDictionary *)operations withSavaPath:(NSString *)savePath withUrlString:(NSString *)urlString withSuccessBlock:(requestSuccess)successBlock withFailureBlock:(requestFailure)failureBlock withDownLoadProgress:(downloadProgress)progress;

@end

NS_ASSUME_NONNULL_END
